package com.cmc.cloud.cmclink.doc.vo.sovo.sovo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import static com.cmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

/**
 * @author 陈正
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SoBsaCountVO {
    @Schema(description = "港口代码", requiredMode = Schema.RequiredMode.REQUIRED)
    private String polCode;
    @Schema(description = "bsa箱量teu")
    private int bsaTeu;
    @Schema(description = "bsa重量吨")
    private int bsaTons;
    @Schema(description = "冷插数")
    private int rfUnit;
    @Schema(description = "HC（teu)")
    private int hcTeu ;
    @Schema(description = "全船接载开关", requiredMode = Schema.RequiredMode.REQUIRED)
    private String bookingOpenStatus;
    @Schema(description = "全船接载开关时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime openCloseTime;
    @Schema(description = "已接TEU")
    private BigDecimal receivedTeu;
    @Schema(description = "已接TEU 阈值")
    private BigDecimal receivedThresholdTeu;
    @Schema(description = "已接Unit")
    private long receivedUnit;
    @Schema(description = "待接Unit")
    private long waitUnit;
    @Schema(description = "待接TEU")
    private BigDecimal waitTeu;
    @Schema(description = "待接TEU 阈值")
    private BigDecimal waitThresholdTeu;
    @Schema(description = "已接TONS(箱货总重)")
    private BigDecimal receivedWgtTons;
    @Schema(description = "待接TONS(箱货总重)")
    private BigDecimal waitWgtTons;
    @Schema(description = "放箱量")
    private long containerReleaseVolume;
    @Schema(description = "进港量")
    private long inboundVolume;

    public BigDecimal getReceivedTeu() {
        if(receivedTeu == null) {
            return BigDecimal.ZERO;
        }
        return receivedTeu;
    }

    public BigDecimal getReceivedThresholdTeu() {
        if(receivedThresholdTeu == null) {
            return BigDecimal.ZERO;
        }
        return receivedThresholdTeu;
    }

    public BigDecimal getWaitTeu() {
        if(waitTeu == null) {
            return BigDecimal.ZERO;
        }
        return waitTeu;
    }

    public BigDecimal getWaitThresholdTeu() {
        if(waitThresholdTeu == null) {
            return BigDecimal.ZERO;
        }
        return waitThresholdTeu;
    }

    public BigDecimal getReceivedWgtTons() {
        if(receivedWgtTons == null) {
            return BigDecimal.ZERO;
        }
        return receivedWgtTons.divide(new BigDecimal(1000), 3);
    }

    public BigDecimal getWaitWgtTons() {
        if(waitWgtTons == null) {
            return BigDecimal.ZERO;
        }
        return waitWgtTons.divide(new BigDecimal(1000), 3);
    }
}
